import { request } from "@/utils/request";

/** MOCK数据 */
export interface NeedsInfo {
  [key: string]: any;
  id: number;
  image?: string;
  name?: string;
  cname?: string;
  mobile?: string;
  email?: string;
  date?: string;
  datetime?: string;
  id_card?: string;
  ip?: string;
  url?: string;
  county?: string;
  csentence?: string;
  boolean?: boolean;
};

/** 获取需求列表 GET /api/need/list */
export async function getList(params: Record<string, any>) {
  return request<API.PagedList<any>>(`/api/need/list`, {
    method: "GET",
    params,
  });
}

/** 获取需求详情 GET /api/need/info */
export async function getDetail(data: Record<string, any>) {
  return request(`/api/need/info`, {
    method: "POST",
    data,
  });
}

/** 提交需求 POST /api/need/save */
export async function postSave(data: Record<string, any>) {
  return request(`/api/need/save`, {
    method: "POST",
    data,
  });
}

/** 获取用户需求列表 GET /api/user/need/list */
export async function getListByUser(params: Record<string, any>) {
  return request<API.PagedList<any>>(`/api/user/need/list`, {
    method: "GET",
    params,
  });
}

/** 获取用户需求详情 GET /api/user/need/info */
export async function getNeedDetailByUser(params: Record<string, any>) {
  return request(`/api/user/need/info`, {
    method: "GET",
    params,
  });
}

/** 删除需求 POST /api/user/need/del */
export async function removeNeed(data: Record<string, any>) {
  return request(`/api/user/need/del`, {
    method: "POST",
    data,
  });
}

/** 需求留言 POST /api/need/saveMsg */
export async function saveMsg(data: Record<string, any>) {
  return request(`/api/need/saveMsg`, {
    method: "POST",
    data,
  });
}
